import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_purchased_subscription_pause_info.dart';
import 'package:backend.purchases/infrastructure/dtos/api/api_time_dto.dart';

const kApiGooglePlayPurchasedSubscriptionPauseAutoResumeTimeKey = 'auto_resume_time';

class ApiGooglePlayPurchasedSubscriptionPauseInfoDto extends Equatable {
  const ApiGooglePlayPurchasedSubscriptionPauseInfoDto._internal({
    required this.autoResumeTimeDto,
  });

  final ApiTimeDto autoResumeTimeDto;

  @override
  List<Object?> get props {
    return [
      autoResumeTimeDto,
    ];
  }

  factory ApiGooglePlayPurchasedSubscriptionPauseInfoDto.fromEntity(
      ApiGooglePlayPurchasedSubscriptionPauseInfo pauseInfo) {
    final autoResumeTimeDto = ApiTimeDto.fromEntity(pauseInfo.autoResumeTime);

    return ApiGooglePlayPurchasedSubscriptionPauseInfoDto._internal(
      autoResumeTimeDto: autoResumeTimeDto,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      kApiGooglePlayPurchasedSubscriptionPauseAutoResumeTimeKey: autoResumeTimeDto.toString(),
    };
  }
}
